<?php
/**
 * Created by PhpStorm.
 * User: zeopean
 * Date: 2015/8/12
 * Time: 16:00
 */
namespace App\Exceptions;

use Exception;

class ProjectMilestoneException extends Exception{
    /**
     * 参数解析
     * NoProjectId          没有项目标识
     * NoMilTime            没有里程碑建立时间
     * NoMilDesc            没有里程碑描述
     */
    const NoProjectId        = 0x01 ;
    const NoMilTime          = 0x02 ;
    const NoMilDesc          = 0x03 ;

    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::NoProjectId:
                $message = trans('exception.project_milestone.no_project_id', ['project_id' => array_get($data, 'project_id')]);
                break;
            case self::NoMilTime:
                $message = trans('exception.project_milestone.no_mil_time', ['mil_time' => array_get($data, 'mil_time')]);
                break;
            case self::NoMilDesc:
                $message = trans('exception.project_milestone.no_mil_desc', ['mil_desc' => array_get($data, 'mil_desc')]);
                break;

            default:
                $message = trans('general.unknown_exception');
                break;
        }

        parent::__construct($message, $code, $previous);
    }
}